<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>${applicationScope.siteName }</title>
<link rel="stylesheet" href="${ctx}/static/bootstrap-3.3.4-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="${ctx}/static/bootstrap-3.3.4-dist/css/wxUserbinding.css">
<script type="text/javascript" src="${ctx}/static/bootstrap-3.3.4-dist/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="${ctx}/static/bootstrap-3.3.4-dist/js/bootstrap.js"></script>
<script type="text/javascript" src="${ctx}/static/bootstrap-table-1.7.0/src/locale/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript">
	var i = 6;
	$(function() {
		$("#binding").click(function() {
			if ($("#openid").val() == "" || $("#appid").val() == "") {
				WeixinJSBridge.call("closeWindow");
				return false;
			}
			if ($("#username").val() == "") {
				alert("用户名不能为空!");
				return false;
			}
			if ($("#password").val() == "") {
				alert("密码不能为空!");
				return false;
			}
			$.post("${ctx}/wxWeb/bindingWxUser/bindingUser", {
				openid : $("#openid").val(),
				appid : $("#appid").val(),
				loginNo : $("#username").val(),
				password : $("#password").val(),
				state : $("#state").val()
			}, function(data) {
				$("#msg").text(data.msg);
				$("#msgDialog").modal("show");
				$("#jumpUrl").val(data.obj.toString());
				if (data.success) {
					//alert("绑定成功!正在自动关闭界面.");
					//界面跳转
					setInterval(fn_showTime, 1000);
				}
			}, "json");
		});
		$("#submit").click(function() {
			$("#msgDialog").modal("hide");
			if ($("#jumpUrl").val() != "") {
				window.open($("#jumpUrl").val());
			}
		});
	});
	function fn_showTime() {
		i--;
		$("#timeshow").text(i + "秒后自动跳转!");
		if (i == 0) {
			window.open($("#jumpUrl").val());
		}
	}
</script>
</head>
<body>
	<div id="auth-wrapper">
		<div id="auth">
			<div id="glyph">
				<a href="#"><label>绑定系统用户</label></a>
			</div>
			<form method="post" class="form-horizontal">
				<input id="openid" type="hidden" name="openid" value="${openid }" /> <input id="appid" type="hidden" name="appid" value="${appid }" /><input
					id="state" type="hidden" name="state" value="${state }" />
				<div class="form-group">
					<label for="userName" class="col-sm-2 control-label">账&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" id="username" name="username" placeholder="Login No" autofocus required>
					</div>
				</div>
				<div class="form-group">
					<label for="password" class="col-sm-2 control-label">密&nbsp;&nbsp;&nbsp;&nbsp;码：</label>
					<div class="col-sm-10">
						<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
					</div>
				</div>
				<button id="binding" type="button" class="btn btn-block btn-primary">绑定</button>
			</form>
		</div>
	</div>
	<div id="msgDialog" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
		aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-body">
					<p id="msg"></p>
					<p id="timeshow"></p>
					<input type="hidden" id="jumpUrl" />
				</div>
				<div class="modal-footer">
					<button id="submit" type="button" class="btn btn-primary">确定</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
</body>
</html>